﻿using Huirui.Cavan.Domain.Seedwork;
using System;
using System.Collections;
using System.Collections.Generic;

namespace Huirui.Cavan.Domain.MainBoundedContext.SystemModule
{
    #region Resource

    /// <summary>
    /// Resource object for NHibernate mapped table 'Resource'.
    /// </summary>
    [Serializable]
    public class Resource : Persistent
    {
        #region Member Variables

        protected string _name;
        protected Module _module;
        protected IList<RoleResource> _roleResources;

        #endregion

        #region Constructors

        public Resource() { }

        public Resource(string name, DateTime createDate, DateTime modifyDate, int editUser, Module module)
        {
            this._name = name;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._editUser = editUser;
            this._module = module;
        }

        #endregion

        #region Public Properties


        public virtual string Name
        {
            get { return _name; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Name", value, value.ToString());
                _name = value;
            }
        }

        public virtual Module Module
        {
            get { return _module; }
            set { _module = value; }
        }

        public virtual IList<RoleResource> RoleResources
        {
            get
            {
                if (_roleResources == null)
                {
                    _roleResources = new List<RoleResource>();
                }
                return _roleResources;
            }
            set { _roleResources = value; }
        }



        #endregion
    }
    #endregion
}